home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 15
/
Aminet 15 - Nov 1996.iso
/
Aminet
/
dev
/
c
/
EasygadgetsSou.lha
/
EasyGadgets
/
Menu.c_backup
< prev
next >
Wrap
Text File
|
1995-02-26
|
3KB
|
145 lines
/*
* File: Menu.c
* Description: A set of functions to manipulate menus.
*
* (C) 1994, Ketil Hunn
*
*/
#ifndef MENUFUNCTIONS_C
#define MENUFUNCTIONS_C
__asm UBYTE *egFindMenuTitle( register __a0 struct Menu *mymenu,
register __d0 ULONG idcmp)
{
register struct Menu *menu;
register struct MenuItem *item, *sub;
register BYTE found=FALSE;
UBYTE *title=NULL;
#ifdef MYDEBUG_H
DebugOut("egFindMenuNum");
#endif
for(menu=mymenu; menu!=NULL & found==FALSE; menu=menu->NextMenu)
{
title=(UBYTE *)menu->MenuName;
for(item=menu->FirstItem; item!=NULL; item=item->NextItem)
{
for(sub=item->SubItem; sub!=NULL & found==FALSE; sub=sub->NextItem)
if(GTMENUITEM_USERDATA(sub)==(APTR)idcmp)
found=TRUE;
if(GTMENUITEM_USERDATA(item)==(APTR)idcmp)
found=TRUE;
}
}
return title;
}
__asm struct MenuItem *egFindMenuItem(register __a0 struct Menu *mymenu,
register __d0 ULONG idcmp)
{
register struct Menu *menu;
register struct MenuItem *item, *sub;
#ifdef MYDEBUG_H
DebugOut("egFindMenuItem");
#endif
for(menu=mymenu; menu!=NULL; menu=menu->NextMenu)
for(item=menu->FirstItem; item!=NULL; item=item->NextItem)
{
for(sub=item->SubItem; sub!=NULL; sub=sub->NextItem)
if(GTMENUITEM_USERDATA(sub)==(APTR)idcmp)
return sub;
if(GTMENUITEM_USERDATA(item)==(APTR)idcmp)
return item;
}
return NULL;
}
__asm __saveds BOOL egIsMenuItemChecked(register __a0 struct Menu *menu,
register __d0 ULONG idcmp)
{
register struct MenuItem *item=egFindMenuItem(menu, idcmp);
#ifdef MYDEBUG_H
DebugOut("egIsMenu_ItemChecked");
#endif
if(item)
if(ISBITSET(item->Flags, CHECKED))
return TRUE;
return FALSE;
}
__asm __saveds void egCheckMenuItem(register __a0 struct Window *window,
register __a1 struct Menu *menu,
register __d0 ULONG idcmp,
register __d1 BOOL check)
{
register struct MenuItem *item=egFindMenuItem(menu, idcmp);
#ifdef MYDEBUG_H
DebugOut("egCheckMenuItem");
#endif
if(window!=NULL)
if(item)
{
ClearMenuStrip(window);
IFTRUESETBIT(check, item->Flags, CHECKED);
ResetMenuStrip(window, menu);
}
}
__asm __saveds void egDisableMenuItem(register __a0 struct Window *window,
register __a1 struct Menu *menu,
register __d0 ULONG idcmp,
register __d1 BOOL flag)
{
register struct MenuItem *item=egFindMenuItem(menu, idcmp);
#ifdef MYDEBUG_H
DebugOut("egDisableMenuItem");
#endif
if(window!=NULL)
if(item)
{
ClearMenuStrip(window);
IFFALSESETBIT(flag, item->Flags, NM_ITEMDISABLED);
ResetMenuStrip(window, menu);
}
}
__asm __saveds void egSetMenuItem(register __a0 struct NewMenu *menuitem,
register __d0 UBYTE type,
register __a1 STRPTR label,
register __d1 UWORD flags,
register __d2 LONG exclude,
register __a2 APTR userdata)
{
if(label==NM_BARLABEL)
{
menuitem->nm_Label =label;
menuitem->nm_CommKey=NULL;
}
else if(*label!=' ' & *(label+1)=='\0')
{
menuitem->nm_Label =label+2;
menuitem->nm_CommKey=label;
}
else
{
menuitem->nm_Label =label;
menuitem->nm_CommKey=NULL;
}
menuitem->nm_Type =type;
menuitem->nm_Flags =flags;
menuitem->nm_MutualExclude=exclude;
menuitem->nm_UserData =userdata;
}
#endif